********** Do File for JOP Article **********

clear
use "C:\Users\davidmacdonald\Dropbox\Final JOP Party Control and Statehouse Democracy\Final JOP Data (1997-2020).dta" 

* Set up data for panel analyses 
xtset State_FE Year_FE

* To use the outreg2 package
ssc install outreg2

* Figure 1 
twoway scatter Policy_Econ_Lib_100 Opin_Econ_Lib_100, by(GOP_Control_Dummy) || lfit Policy_Econ_Lib_100 Opin_Econ_Lib_100, by(GOP_Control_Dummy)

* Table 1 
xtpcse Policy_Econ_Lib_100 c.Opin_Econ_Lib_100##i.Party_Control4 i.State_FE i.Year_FE
outreg2 using tab.tex, dec(3) sideway asterisk(se) replace 

* Figure 2 
xtpcse Policy_Econ_Lib_100 c.Opin_Econ_Lib_100##i.Party_Control4 i.State_FE i.Year_FE
margins, dydx(Opin_Econ_Lib_100) at(Party_Control4=(0 1 2 3))
marginsplot 

* Figure 3
twoway scatter Policy_Cult_Lib_100 Opin_Cult_Lib_100, by(GOP_Control_Dummy) || lfit Policy_Cult_Lib_100 Opin_Cult_Lib_100, by(GOP_Control_Dummy)

* Table 2 
xtpcse Policy_Cult_Lib_100 c.Opin_Cult_Lib_100##i.Party_Control4 i.State_FE i.Year_FE
outreg2 using tab.tex, dec(3) sideway asterisk(se) replace 

* Figure 4 
xtpcse Policy_Cult_Lib_100 c.Opin_Cult_Lib_100##i.Party_Control4 i.State_FE i.Year_FE
margins, dydx(Opin_Cult_Lib_100) at(Party_Control4=(0 1 2 3))
marginsplot 


********** Supplemental Appendix **********

* Appendix A *
clear
use "C:\Users\davidmacdonald\Dropbox\Final JOP Party Control and Statehouse Democracy\Final JOP Data (1997-2020).dta" 

sum Policy_Econ_Lib_100
sum Opin_Cult_Lib_100 
sum Policy_Econ_Lib_100
sum Opin_Cult_Lib_100 
tab Party_Control4
tab Type_GOP_Control

list Name_State_Year if Party_Control4==0
list Name_State_Year if Party_Control4==1
list Name_State_Year if Party_Control4==2
list Name_State_Year if Party_Control4==3

list Name_State_Year if Type_GOP_Control==1
list Name_State_Year if Type_GOP_Control==2

* Appendix B *
clear
use "C:\Users\davidmacdonald\Dropbox\Final JOP Party Control and Statehouse Democracy\Final JOP Data (1997-2020).dta" 

* Set up data for panel analyses 
xtset State_FE Year_FE

* To use the outreg2 package
ssc install outreg2

* Table B1 
xtpcse Policy_Econ_Lib_100 c.Opin_Econ_Lib_100##i.Party_Control4 i.State_FE i.Year_FE
outreg2 using tab.tex, dec(3) replace
reg Policy_Econ_Lib_100 c.Opin_Econ_Lib_100##i.Party_Control4 i.State_FE i.Year_FE, cluster(State_FE)
outreg2 using tab.tex, dec(3) append 
xtpcse Policy_Cult_Lib_100 c.Opin_Cult_Lib_100##i.Party_Control4 i.State_FE i.Year_FE
outreg2 using tab.tex, dec(3) append 
reg Policy_Cult_Lib_100 c.Opin_Cult_Lib_100##i.Party_Control4 i.State_FE i.Year_FE, cluster(State_FE)
outreg2 using tab.tex, dec(3) append 

* Table B2 
xtpcse Policy_Econ_Lib_100 c.Opin_Econ_Lib_100##i.Party_Control4 i.State_FE i.Year_FE
outreg2 using tab.tex, dec(3) replace
xtpcse Policy_Econ_Lib_100 c.Opin_Econ_Lib_100##i.Party_Control4 Lag_Policy_Econ_Lib_100 i.State_FE i.Year_FE
outreg2 using tab.tex, dec(3) append
xtpcse Policy_Cult_Lib_100 c.Opin_Cult_Lib_100##i.Party_Control4 i.State_FE i.Year_FE
outreg2 using tab.tex, dec(3) append 
xtpcse Policy_Cult_Lib_100 c.Opin_Cult_Lib_100##i.Party_Control4 Lag_Policy_Cult_Lib_100 i.State_FE i.Year_FE
outreg2 using tab.tex, dec(3) append

* Table B3 
xtpcse Policy_Econ_Lib_100 c.Opin_Econ_Lib_100##i.Type_GOP_Control i.State_FE i.Year_FE
outreg2 using tab.tex, dec(3) replace 
xtpcse Policy_Cult_Lib_100 c.Opin_Cult_Lib_100##i.Type_GOP_Control i.State_FE i.Year_FE
outreg2 using tab.tex, dec(3) append 
